Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: OpenDoc Programmer's Guide / Part 2 - Programming
Chapter 6 - Windows and Menus


Controls

This section discusses what kinds of controls you can use, how you can construct them, and how to handle events within controls. It also discusses two specific issues for palettes: how to share them among instances of your part, and how to use them to embed parts within your part.

Design Issues for Controls

Controls in OpenDoc have the same function as in conventional applications: they are graphical objects that allow the user to interact with and manipulate documents in a variety of ways. However, there are some differences:

Standard types of controls you might wish to include with your parts include

Rulers usually reflect some settings of the current selection context and contain controls that allow the user to change these settings. Tool bars are like rulers, but they often trigger actions instead of changing settings. Status bars display the progress of some long-running operation or suggest actions to users.

In conventional applications, rulers, tool bars, and status bars commonly occupy the margins of the window. In an OpenDoc document, controls can appear within the frame they apply to, or in separate frames outside the frame they apply to.

A ruler for a text part, for example, can be an additional frame associated with the part. Events in the ruler are handled by the part's editor. Alternatively, the ruler may be its own part with its own editor. In this case, the text part editor must maintain a reference to the ruler part and be able to communicate with it through semantic events or some other extension mechanism.

A ruler that is a separate part can have its own embedded parts, such as buttons. The ruler part must then be able to communicate with its embedded controls as well as with the part that it services.

Palettes often contain editing tools but can also contain choices for object attributes such as color or line width. Palettes commonly float freely beside or over the document, although they can also be fixed at the window margins. Palettes might also be pop-up, pull-down, or tear-off menus.

If all parts in a document can communicate with each other, they can coordinate the drawing and hiding of palettes or other controls, to avoid irritating the user. For example, all parts in a document can share a single palette. The various parts negotiate for space within the palette, and they draw or erase only those tools that change as the active part changes.

Handling Events in Controls

How you handle events in a control depends on how you design the control.

Sharing Palettes and Utility Windows

The user-interface guidelines presented in the section "Palettes and Tool Bars" state that you should hide any visible palettes, modeless dialog boxes, or other utility windows when your part becomes inactive or its document closes, and restore them--in the same positions--when the part becomes active once again or the document reopens. In addition, if your part editor maintains multiple parts in a document and the active state switches from one to another of them, any visible utility windows that apply to both parts should remain steadily visible, without any flicker caused by hiding and immediate restoring.

One way to implement this behavior for a utility window is to follow, in general, steps such as these:

Using a Tool Palette to Embed Parts

An example of an OpenDoc-specific use of controls is to allow the user to embed parts by selecting items from a palette. Using a palette in this way, your part can create embedded parts from scratch rather than by reading in existing part data.

Your part can provide a palette, menu, or dialog box from which the user selects an item that specifies a part kind. As in many conventional applications, your palette could display a set of tools to the user--drawing tools, painting tools, text tools, and so on. In this case, however, selecting an item from the palette actually means that a new part of that kind is to be embedded in your part. The section "Creating Parts From Tool Palettes" describes interface guidelines for presenting such a palette to the user.

The items could represent existing stationery documents in the user's system, or they could simply represent individual part kinds for which editors exist. If you are creating parts from scratch, follow steps such as these once the user has made a selection from your palette:

  1. Create the new part by calling your draft's CreatePart method, passing it the part kind that the user selected.
  2. Call the new part's Externalize method (see "The Externalize Method") so that the part can create and write initial data to the properties in its storage unit.
  3. Create a new embedded frame for the part, as described in "Creating a New Embedded Frame".
  4. Give the new frame the proper link status, as described in "Frame Link Status".
  5. If the new frame is visible, assign facets to it, as described in the section "Adding a Facet".
  6. Notify your containing part and your draft that there has been a change to your part's content; see "Making Content Changes Known"


Previous Book Contents Book Index Next

© Apple Computer, Inc.
16 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help